package com.zbl.springdemo.bean.lifecycle;

import org.springframework.beans.BeansException;
import org.springframework.beans.factory.config.BeanPostProcessor;
import org.springframework.stereotype.Component;

@Component
public class BeanPostProcessorDemo implements BeanPostProcessor {
    @Override
    public Object postProcessBeforeInitialization(Object bean, String beanName) throws BeansException {
        if (!"beanDemo".equals(beanName)) {
            return bean;
        }
        System.out.println("对象初始化前置操作");
        return bean;
    }

    @Override
    public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException {
        if (!"beanDemo".equals(beanName)) {
            return bean;
        }
        System.out.println("对象初始化后置操作");
        return bean;
    }
}
